<?php
/*
 *   This file is part of verbum.
 *
 *   poat is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   poat is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with poat.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * 	 Copyright (c) 2008 Sergio Gabriel Teves <gabriel.sgt at gmail.com>
 */
/*
include_once("../includes/init.php");

$a = new stdClass();
$a->uno="";
$a->dos="DOS";
print String::coallesce($a->uno,$a->dos);
*/

/*
include_once("../includes/init.php");

$usernotList = new maplist;

$elem = array("file" => "algo","prj" => "mas","sprj" => "otro");
$elem1 = array("file" => "algo1","prj" => "mas1","sprj" => "otro1");
$usernotList->add("pepe",$elem);
$usernotList->add("pepe",$elem1);
	
$list = $usernotList->getAll();
foreach ($list as $k => $v) {
	$flist = array();
	foreach ($v as $f) {
		$flist[]=$f;	
	}
	echo "V ";
	print_r($v);
	echo "<br>F ";
	print_r($flist);
}

*/
/*
$t = new teamsetting;
$t->teamid="1";
$t->id="2";
$loader->get($t);
print utf8_decode(jsCleanSlashes($t->value));
*/
/*
$matcharr = array(
	array("reg"=>"/\b_\(\'.+\'\)/","start"=>"_('","end"=>"')"),
	array("reg"=>"/\b_\(\".+\"\)/","start"=>"_(\"","end"=>"\")"),
	array("reg"=>"/\bs\(\'.+\'\)/","start"=>"s('","end"=>"')"),
	array("reg"=>"/\bs\(\".+\"\)/","start"=>"s(\"","end"=>"\")"),
	array("reg"=>"/\bs\(\".+\",[A-Za-z_\"\'$-> ]*(\))?(,[A-Za-z ]+)?\)/","start"=>"s(\"","end"=>"\","),
	array("reg"=>"/\bs\(\'.+\',[A-Za-z_\"\'$-> ]*(\))?(,[A-Za-z ]+)?\)/","start"=>"s('","end"=>"',"),
	array("reg"=>"/<text>.+<\/text>/","start"=>"<text>","end"=>"</text>"),
	);

$lines = file("test.txt");

foreach ($lines as $line) {
	foreach ($matcharr as $mt) {
		//echo "$line<br>";
		$rline = $line;
		while(preg_match($mt['reg'], $rline, $matches)) {
			echo ">>>>>>>>>>> MATCH ";
			$s = strpos($matches[0],$mt['start']);
			if ($s===false) break;
			$f = strpos ($matches[0],$mt['end'],$s);
			$str = addslashes((substr($matches[0],$s+strlen($mt['start']),$f-($s+strlen($mt['start'])))));
			print $str."<br>";
	
			$rline = substr($matches[0],$f);				
		}
	}
}
	*/
/*
$cadena = 'Ask for an account here.\nThe message will be sent to the team coordinator.\nSometimes it is recommended to join the mailing list opensuse-translation@opensuse.org.\nIf the desired team does not exists, select Administrator.';

$tiempo_inicio = microtime(true);
$str = md5($cadena);
$tiempo_final = microtime(true);
$tiempo = $tiempo_final - $tiempo_inicio;
printf("MD5 %.20f [%s]<br>", $tiempo,$str);

$tiempo_inicio = microtime(true);
$str = sha1($cadena);
$tiempo_final = microtime(true);
$tiempo = $tiempo_final - $tiempo_inicio;
printf("SHA %.20f [%s]<br>", $tiempo,$str);

$tiempo_inicio = microtime(true);
$str = base64_encode($cadena);
$tiempo_final = microtime(true);
$tiempo = $tiempo_final - $tiempo_inicio;
printf("B64 %.20f [%s]<br>", $tiempo,$str);

$tiempo_inicio = microtime(true);
$str = convert_uuencode($cadena);
$tiempo_final = microtime(true);
$tiempo = $tiempo_final - $tiempo_inicio;
printf("UUE %.20f [%s]<br>", $tiempo,$str);
*/

include("../rpc/xmlrpc.inc");
require_once("../class/Services_JSON.class.php");
require_once("../class/xml2json.class.php");

$m = new xmlrpcmsg('suggest',array(new xmlrpcval("plasmoid"),new xmlrpcval("es")));
$c = new xmlrpc_client("http://open-tran.eu/RPC2");
$c->proxy='localhost';
$c->proxyport=3128;
$r = $c->send($m);
if (!$r->faultCode()) {
	print htmlentities($r->serialize()) . "<BR>" ;
	/*
	print_r(count($r->value()->me['array']));
	echo "<br>";
	foreach ($r->value()->me['array'] as $rr) {
		print_r($rr->me['struct']['text']->me['string'])."<br>";
	}
	//print_r($r->value()->me['array'][0]->me['struct']['text']->me['string']);
	print htmlentities($r->serialize()) . "<BR>" ;
	*/
}
/*
	$valor = $r->serialize();
	$valor = file_get_contents("res.xml");
	//print htmlentities($valor);
	$sxml = simplexml_load_string($valor);
	$resp = $sxml->params->param->value->array->data->asXML();
	echo htmlentities($resp);
	//print $sxml->params;
	//echo htmlentities($sxml);
	$jsonContents = xml2json::transformXmlStringToJson($resp);
	echo($jsonContents."<br>");
	$con = json_decode($jsonContents);
	print_r($con);
	*/
	/*
 else {
	print "Fault <BR>";
	print "Code: " . htmlentities($r->faultCode()) . "<BR>" .
	"Reason: '" . htmlentities($r->faultString()) . "'<BR>";
}
*/
?>

